#include "thread_pool.h"

//查看日志指令: tail /var/log/syslog
void addConnectLog(int peerfd)
{
    openlog("[PROGRAM LOG]User connecting!",LOG_CONS,0);
    syslog(LOG_INFO,"User %d is connecting.",peerfd);
    closelog();
}


void addUseLog(task_t * task)
{
    char Cmd[128] = {0};
    switch(task->type)
    {
    case CMD_TYPE_PWD:
        strcpy(Cmd,"pwd"); break;
    case CMD_TYPE_CD:
        strcpy(Cmd,"cd"); break;
    case CMD_TYPE_LS:
        strcpy(Cmd,"ls"); break;
    case CMD_TYPE_MKDIR:
        strcpy(Cmd,"mkdir"); break;
    case CMD_TYPE_RMDIR:
        strcpy(Cmd,"rmdir"); break;
    case CMD_TYPE_NOTCMD:
        strcpy(Cmd,"notcmd"); break;
    case CMD_TYPE_PUTS:
        strcpy(Cmd,"puts"); break;
    case CMD_TYPE_GETS:
        strcpy(Cmd,"gets"); break;

    case TASK_LOGIN_SECTION1:
        strcpy(Cmd,"login name:"); break;
    case TASK_LOGIN_SECTION2:
        strcpy(Cmd,"login passwd:"); break;
    case TASK_REGISTER_SECTION1:
        strcpy(Cmd,"register username:"); break;
    case TASK_REGISTER_SECTION2:
        strcpy(Cmd,"register passwd:"); break;
    }
    openlog("[PROGRAM LOG]User typing!",LOG_CONS,0);
    syslog(LOG_INFO,"CMD:%s:%s",Cmd,task->data);
    closelog();
}

